package com.lagou.edu.service.impl;

import com.lagou.edu.service.TPMonitorService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author 赵虎
 * @date 2021/1/11 2:00 上午
 */
@Service
public class TPMonitorServiceImpl implements TPMonitorService {

    @Override
    public int methodA() {
        return sleepTime();
    }

    @Override
    public int methodB() {
        return sleepTime();
    }

    @Override
    public int methodC() {
        return sleepTime();
    }

    private int sleepTime() {
        int i = new Random().nextInt(100);
        try {
            TimeUnit.MILLISECONDS.sleep(i);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("sleep:" + i);
        return i;
    }
}
